﻿@{
    //page title
    ViewBag.Title = T("Admin.Promotions.Campaigns").Text;
}

<div class="row">
    <div class="col-md-12">
        <div class="x_panel light form-fit">
            <div class="x_title">
                <div class="caption">
                    <i class="fa fa-envelope"></i>
                    @T("Admin.Promotions.Campaigns")
                </div>
                <div class="actions btn-group btn-group-devided">
                    <a href="@Url.Action("Create")" class="btn green"><i class="fa fa-plus"></i><span class="d-none d-sm-inline"> @T("Admin.Common.AddNew") </span></a>
                </div>
                <vc:admin-widget widget-zone="campaign_list_buttons" additional-data="null" />
            </div>
            <div class="x_content form">
                <div class="form-horizontal">
                    <div class="form-body">
                        <div class="x_content">
                            <div id="campaigns-grid"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
$(document).ready(function () {
    $("#campaigns-grid").kendoGrid({
        dataSource: {
            transport: {
                read: {
                    url: "@Html.Raw(Url.Action("List", "Campaign"))",
                    type: "POST",
                    dataType: "json",
                    data: addAntiForgeryToken
                }
            },
            schema: {
                data: "Data",
                total: "Total",
                errors: "Errors"
            },
            error: function(e) {
                display_kendoui_grid_error(e);
                // Cancel the changes
                this.cancelChanges();
            },
            serverPaging: true,
            serverFiltering: true,
            serverSorting: true
        },
        pageable: {
            refresh: true,
            numeric: false,
            previousNext: false,
            info: false
        },
        editable: {
            confirmation: false,
            mode: "inline"
        },
        scrollable: false,
        columns: [{
            field: "Name",
            title: "@T("Admin.Promotions.Campaigns.Fields.Name")",
            template: '<a class="k-link" href="Edit/#=Id#">#=kendo.htmlEncode(Name)#</a>',
        }, {
            field: "CreatedOn",
            title: "@T("Admin.Promotions.Campaigns.Fields.CreatedOn")",
            width: 200,
            type: "date",
            format: "{0:G}"
        }]
    });
});
</script>
